package com.cpx.config;

import org.springframework.core.convert.converter.Converter;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

/**
 * @Auther: PanBin
 * @Date: 2018-8-29 16:02
 * @Description: 自定义的时间转换组件
 * @Version: 1.0
 */
public class DateConverterConfig implements Converter<Date,String> {

    private DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    @Override
    public String convert(Date source) {
        if (source == null) {
            return null;
        }
        return df.format(source);
    }
}
